﻿// See https://aka.ms/new-console-template for more information
using System;
using System.Diagnostics;
using MathNet.Numerics.Statistics;
using phminarm.algorithm.Base;
using phminarm.algorithm.DataProcess;
using phminarm.algorithm.FeatureExtraction;
using phminarm.algorithm.Health;

namespace ConsoleApp // Note: actual namespace depends on the project name.
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //生成模拟数据
            int N = 131072;
            float fs = 25600;
            float A = 10;
            float f = 24;
            float t = N / fs;
            float[] data = new float[N];
            for (int i = 0; i < N; i++)
            {
                data[i] = Convert.ToSingle(A * Math.Sin(2 * Math.PI * f * i / fs));
            }
            //健康评估
            {
                ////初始化时需要读取配置文件
                //HealthByWeight hw = new HealthByWeight("./configfiles/weight_pump.txt");
                ////模拟的机组运行参数
                //float[][] p = new float[2][];
                //p[0] = new float[] { 10, 2, 1, 4 };//部件1的运行参数
                //p[1] = new float[] { 1, 20, 3, 4 };
                ////计算机组健康度
                //hw.CalcHealthByWeight(p);
                ////读取机组整机健康度
                //Console.WriteLine($"整机健康度为:{hw.Health}");
                ////读取机组各个部件的健康度
                //Console.WriteLine("机组部件健康度为:" + string.Join(",", hw.Health_Part));
            }
            //fft
            {

                ////调用函数
                //float[] spec, pha;
                //(spec, pha) = FFTWraper.GetFFTAmp(data.ToArray());
                ////存储fft结果
                ////var path = AppDomain.CurrentDomain.BaseDirectory;
                //StreamWriter sw = new StreamWriter(@"output.txt", false);
                //foreach (float a in spec)
                //{
                //    sw.WriteLine(a);
                //}
                //sw.Close();
            }
            //特征提取
            {
                //TimeDomainFeatures tdf = new TimeDomainFeatures(data);
                //tdf.GetAllTimeDomainFeatures();
                //FrequencyDomainFeatures fdf = new FrequencyDomainFeatures(data, fs);
                //fdf.GetAllFrequencyFeatures(10, 10000);
                //Bear bear = new Bear(95, 105, 10, 10, 1, 0, red: 5, ren: 10);
                //List<Bear> bears = new List<Bear>();
                //bears.Add(bear);
                //fdf.GetBearFeature(bears, new float[] { 3000f });
                //fdf.GetSpeedMultiplication(f, 10);
            }
            //寻峰值
            {
                //FindPeaks findPeaks = new FindPeaks();
                ////调用方法
                //Stopwatch sw = new Stopwatch();
                //sw.Start();
                //int[] index = findPeaks.go(data, 10);
                //sw.Stop();
                //Console.WriteLine("寻峰值耗时:" + sw.ElapsedMilliseconds + "ms");
            }
            //专家系统测试
            {
                //phminarm.expert.Test.Go();
            }
            Console.ReadLine();
        }
    }
}

